from rest_framework.fields import SerializerMethodField
from rest_framework.serializers import ModelSerializer

from course.models import Teacher, Course


class TeacherSer(ModelSerializer):
    class Meta:
        model = Teacher
        fields = '__all__'
class CourseSer(ModelSerializer):
    tea=SerializerMethodField(read_only=True)
    def get_tea(self,obj):
        return {'name':obj.teacher.name,"job":obj.teacher.job,'headimg':obj.teacher.headimg,'intro':obj.teacher.intro}
    class Meta:
        model = Course
        fields = '__all__'
